package com.ry.service.controller;

import com.ry.service.client.ServiceAClient;
import com.ry.service.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/feign/user")
public class FeignController {

	@Autowired
	private ServiceAClient serviceA;

	@RequestMapping(value = "/sayHello/{id}", method = RequestMethod.GET)
	public String greeting(@PathVariable("id") Long id, @RequestParam("name") String name, @RequestParam("age") Integer age) {

		return serviceA.sayHello(id, name, age);
	}

	@RequestMapping(value = "/createUser", method = RequestMethod.POST)
	public String createUser(@RequestBody User user) {
		return serviceA.createUser(user);
	}

	@RequestMapping(value = "getById/{id}", method = RequestMethod.GET)
	public User getById(@PathVariable("id") Long id) {
		return serviceA.getById(id);
	}

}
